<%@ page import="java.sql.*" %><%--
  Created by IntelliJ IDEA.
  User: j
  Date: 2020/10/16
  Time: 15:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    Class.forName("com.mysql.jdbc.Driver");
    String url = "jdbc:mysql://localhost:3306/book";

    Connection connection = DriverManager.getConnection(url, "root", "root");

    Statement stmt = connection.createStatement();

    String sql = "select * from user where username = ? and password = ?";
    PreparedStatement pstm = connection.prepareStatement(sql);

    pstm.setString(1,request.getParameter("username"));

    pstm.setString(2,request.getParameter("password"));

    ResultSet rs = pstm.executeQuery();

    //ResultSet rs = stmt.executeQuery(sql);

    while (rs.next()){
        out.print(rs.getString("username")+"-"+rs.getString(3)+"<br>");
    }
%>

</body>
</html>